window.onload = function() {

    function searchMyShops(){
        document.getElementById("bodyMain").innerHTML=`
        <div class="myMessage" id="myMessage"></div>
        `
        axios.get('/home/shopstage/bussiness/getAllShops',{
            params:{

            }
        }).then(function(data){
            if(data.data.data.code==20000){
                var list = data.data.data.data
                console.log("--------------------")
                console.log(list)
                if(list.length == 0){
                    document.getElementById("myMessage").innerHTML = ``
                    document.getElementById("myMessage").innerHTML += `
                    <div class="order">我的商品</div>
                    <div class="nothing">这里什么也没有哦，赶紧去添加商品吧</div>
                    `
                }else{
                    document.getElementById("bodyMain").innerHTML=`
                    <div class="myMessage" id="myMessage">
                    </div>
                    <button class="addShop" onclick="addShop()">
                        添加店铺
                    </button>
                    `
                    document.getElementById("myMessage").innerHTML=`<div class="order">我的店铺</div>`
                    for(i=0;i<list.length;i++){
                        document.getElementById("myMessage").innerHTML +=`
                        <div class="myShops">
                            <div class="shopname" id="shopname">${list[i].shopName}</div>
                            <div class="shopchoose">
                                <div class="shopTops">默认店铺</div>
                                <input class="default" type="checkbox">
                            </div>
                            <div class="shopsign">
                                <img src="${list[i].cover}">
                            </div>
                            <div class="shopnews">
                                <div class="shopTops">店铺消息</div>
                                <div class="news">
                                    <div class="addedOrder">新增订单:0</div>
                                    <div class="addedTalk">新增评论:0</div>
                                    <div class="addedSee">店铺信誉:${list[i].shopScore}</div>
                                    <div class="addedReturn">退货申请:0</div>
                                </div>
                            </div>
                            <div class="thisAddress">
                                <div class="shopTops">店铺地址</div>
                                <div class="thisAddre">${list[i].shopAddress}</div>
                            </div>
                            <div class="shopoperate">
                                <div class="shopTops">店铺操作</div>
                                <div class="operates">
                                    <button onclick="deleteThisShop(${list[i].shopId})">注销店铺</button>
                                    <button onclick="enterThisShop(${list[i].shopId})">进入店铺</button>
                                </div>
                            </div>
                        </div>
                        `
                    }
                    sessionStorage.setItem("shopId",list[0].shopId)
                }
            }else{
                console.log(data.data.data)
                document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>${data.data.data.data}</div><button onclick='closethis()' class='newbtn'>确定</button>`;
                document.getElementById("floatContent").classList.remove("hide");
            }
        }).catch(function (error){
            console.log(error)
            document.getElementById("floatContent").innerHTML ="<div>"+ "很抱歉"+"</div>"+"<div>"+"请检查网络情况"+"</div>"+"<button onclick='closethis()' class='newbtn'>"+"确定"+"</button>";
            document.getElementById("floatContent").classList.remove("hide");
        })
    }
    (function(){searchMyShops()})();
    function enterThisShop(shopId){
        sessionStorage.removeItem("shopId")
        sessionStorage.setItem("shopId",shopId)
    }

    // var pages = document.querySelectorAll(".page")
    // function changePageSize(){
    //     document.getElementById("pageSize").onchange = function(){
    //         console.log(1)
    //         getGoodinShop(1)
    //     }
    // }
    // function getGoodinShop(pageNo,shopId){
    //     changePageSize()
    //     let pageSize =parseInt(document.getElementById("pageSize").value)
    //     axios.post('/home/shopstage/getShopAllGoods',{
    //         params:{
    //             page:pageNo,
    //             pageSize:pageSize,
    //             shopId:shopId
    //         }
    //     }).then(function(data){
    //         if(data.data.data.code==20000){
    //             var list = data.data.data.data
    //             var pagelist = data.data.data.page
    //             if(list.length == 0){
    //                 document.getElementById("myMessage").innerHTML = ``
    //                 document.getElementById("myMessage").innerHTML += `
    //                 <div class="order">我的商品</div>
    //                 <div class="nothing">这里什么也没有哦，赶紧去添加商品吧</div>
    //                 `
    //             }else{
    //                 console.log(list)
    //                 document.getElementById("myMessage").innerHTML = `
    //                 <div class="order">我的商品</div>
    //                     <div class="myGoods">
    //                             <table id="table">
    //                                 <thead class="thead">
    //                                 <tr>
    //                                     <th class="th1">商品信息</th>
    //                                     <th class="th2">当前价</th>
    //                                     <th class="th4">库存</th>
    //                                     <th class="th5">累计销量</th>
    //                                     <th class="th6">上架时间</th>
    //                                     <th class="th7">操作</th>
    //                                 </tr>
    //                                 </thead>
    //                                 <tbody id="tbody">
    //                                 </tbody>
    //                             </table>
    //                     </div>
    //                 `
    //                 for(let i = 0;i<list.length;i++){
    //                     document.getElementById("tbody").innerHTML += `
    //                     <tr>
    //                     <td>
    //                         <img src="/static/home/img/2.png">
    //                         <div class="message">${list[i][0].goodsName}</div>
    //                     </td>
    //                     <td>
    //                         <div class="price">${list[i][0].goodsPrice}</div>
    //                         <div class="changeprice">修改价格</div>
    //                     </td>
    //                     <td>
    //                         <div class="stock">${list[i][0].stock}</div>
    //                         <div class="changestock">修改库存</div>
    //                     </td>
    //                     <td>
    //                         <div class="sold">${list[i][0].monthlySales}</div>
    //                     </td>
    //                     <td>
    //                         <div class="time">${list[i][0].time}</div>
    //                     </td>
    //                     <td>
    //                         <div class="change">编辑</div>
    //                         <div class="takeOff" onclick="deleteOneGood(${list[i][0].goodsId},${list[i][0].userId})">下架</div>
    //                     </td>
    //                 </tr>
    //                     `
    //                 }
    //                 if(pagelist.pageNoTotal <= 5){
    //                     document.getElementById("pagebox").innerHTML = ``
    //                     for(let i=1;i<=pagelist.pageNoTotal;i++){
    //                         document.getElementById("pagebox").innerHTML += `
    //                         <button class="page">${i}</button>
    //                         `
    //                     }
    //                     pages[pageNo-1].style.backgroundColor = "#F96C0C"
    //                     pages[pageNo-1].style.color = "white"
    //                 }else{
    //                     console.log(pagelist.pageNoTotal)
    //                     if(pageNo<=2){
    //                         console.log(pagelist)
    //                         console.log(pageSize)
    //                         document.getElementById("pagebox").innerHTML = ``
    //                         for(let i=1;i<=5;i++){
    //                             document.getElementById("pagebox").innerHTML += `
    //                             <button class="page">${i}</button>
    //                             `
    //                         }
    //                         var pages = document.querySelectorAll(".page")
    //                         for(let j=0;j<5;j++){
    //                             pages[j].style.backgroundColor = "wheat"
    //                             pages[j].style.color = "black"
    //                         }
    //                         pages[pageNo-1].style.backgroundColor = "#F96C0C"
    //                         pages[pageNo-1].style.color = "white"
    //                     }else if(pageNo >= pagelist.pageNoTotal-1){
    //                         console.log(pagelist)
    //                         document.getElementById("pagebox").innerHTML = ``
    //                         for(let i=1;i<=5;i++){
    //                             document.getElementById("pagebox").innerHTML += `
    //                             <button class="page">${pagelist.pageNoTotal+i-5}</button>
    //                             `
    //                         }
    //                         var pages = document.querySelectorAll(".page")
    //                         for(let j=0;j<5;j++){
    //                             pages[j].style.backgroundColor = "wheat"
    //                             pages[j].style.color = "black"
    //                         }
    //                         pages[pageNo-pagelist.pageNoTotal+4].style.backgroundColor = "#F96C0C"
    //                         pages[pageNo-pagelist.pageNoTotal+4].style.color = "white"
    //                     }else{
    //                         console.log(pagelist)
    //                         document.getElementById("pagebox").innerHTML = ``
    //                         for(let i=1;i<=5;i++){
    //                             document.getElementById("pagebox").innerHTML += `
    //                             <button class="page">${pageNo+i-3}</button>
    //                             `
    //                         }
    //                         var pages = document.querySelectorAll(".page")
    //                         for(let j=0;j<5;j++){
    //                             pages[j].style.backgroundColor = "wheat"
    //                             pages[j].style.color = "black"
    //                         }
    //                         pages[2].style.backgroundColor = "#F96C0C"
    //                         pages[2].style.color = "white"
    //                     }
    //                 }
    //             }
    //             var a = 1;
    //             var pages = document.querySelectorAll(".page")
    //             for(let i=0;i<pages.length;i++){
    //                 pages[i].onclick = () =>{     //这个点击事件只是切换到第几页
    //                     a = parseInt(pages[i].innerHTML)
    //                     console.log(a)
    //                     getGoodinShop(a)
    //                 }
    //             }
    //             document.getElementById("leftbtn").onclick = () =>{
    //                 if(pageNo == 1){
    //                     document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>页数不可以小于1</div><button onclick='closethis()' class='newbtn'>确定</button>`;
    //                     document.getElementById("floatContent").classList.remove("hide");
    //                 }else{
    //                     a = pageNo - 1
    //                     getGoodinShop(a)
    //                 }
    //             }
    //             document.getElementById("rightbtn").onclick = () =>{
    //                 console.log(pagelist.pageNoTotal)
    //                 if(pageNo == pagelist.pageNoTotal){
    //                     document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>后面没有内容了</div><button onclick='closethis()' class='newbtn'>确定</button>`;
    //                     document.getElementById("floatContent").classList.remove("hide");
    //                 }else{
    //                     a = pageNo + 1
    //                     getGoodinShop(a)
    //                 }
    //             }
    //             document.getElementById("jumpto").onclick = () =>{
    //                 var pagenumber = parseInt(document.getElementById("pagenumber").value)
    //                 if(pagenumber>=1&&pagenumber<=pagelist.pageNoTotal){
    //                     console.log(pagenumber)
    //                     getGoodinShop(pagenumber)
    //                 }
    //             }
    //             document.getElementById("turnToFirst").onclick = () =>{
    //                 getGoodinShop(1)
    //             }
    //             document.getElementById("turnToLast").onclick = () =>{
    //                 var b =parseInt(pagelist.pageNoTotal) 
    //                 getGoodinShop(b)
    //             }
    //         }else{
    //             console.log(data.data.data.data)
    //             document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>${data.data.data.data}</div><button onclick='closethis()' class='newbtn'>确定</button>`;
    //             document.getElementById("floatContent").classList.remove("hide");
    //         }
    //     }).catch(function (error){
    //         console.log(error)
    //         document.getElementById("floatContent").innerHTML ="<div>"+ "很抱歉"+"</div>"+"<div>"+"请检查网络情况"+"</div>"+"<button onclick='closethis()' class='newbtn'>"+"确定"+"</button>";
    //         document.getElementById("floatContent").classList.remove("hide");
    //     })
    // }
    // (function(){getGoodinShop(1)})();
}
function enterThisShop(shopId){
    sessionStorage.removeItem("shopId")
    sessionStorage.setItem("shopId",shopId)
}
function changePageSize(){
    document.getElementById("pageSize").onchange = function(){
        getGoodinShop(1)
    }
}
function jumpto(){
    document.querySelector(".bodyMain").innerHTML=`
    <div class="myMessage" id="myMessage">
    </div>
    <div id="paging">
                    <select name="pageSize" id="pageSize">
                        <option value="5">5条/页</option>
                        <option value="10">10条/页</option>
                        <option value="15">15条/页</option>
                    </select>
                    <button id="turnToFirst">首页</button>
                    <span class="span">当前页数</span>
                    <i class="fa fa-angle-left fa-1g" aria-hidden="true" id="leftbtn"></i>
                    <span class="pagebox" id="pagebox">
                        <button class="page">1</button>
                        <button class="page">2</button>
                        <button class="page">3</button>
                        <button class="page">4</button>
                        <button class="page">5</button>
                    </span>
                    <i class="fa fa-angle-right fa-1g" aria-hidden="true" id="rightbtn"></i>
                    <button id="turnToLast">尾页</button>
                    <input type="text" name="pagenumber" class="pagenumber" id="pagenumber" onkeyup="this.value=this.value.replace(/[^\d{0-9}]/g,'')" maxlength="2" placeholder="">页
                    <button class="jumpto" id="jumpto">跳转</button>
                </div>
    `
}
function jumpTogetGoodinShop(){
    jumpto()
    changePageSize()
    getGoodinShop(1);
}
function getGoodinShop(pageNo){
    var shopId = sessionStorage.getItem("shopId")
    let pageSize =parseInt(document.getElementById("pageSize").value)
    axios.get('/home/shopstage/bussiness/getShopAllGoods',{
        params:{
            page:pageNo,
            pageSize:pageSize,
            shopId:shopId
        }
    }).then(function(data){
        if(data.data.data.code==20000){
            var list = data.data.data.data
            var pagelist = data.data.data.page
            if(list.length == 0){
                document.getElementById("myMessage").innerHTML = ``
                document.getElementById("myMessage").innerHTML += `
                <div class="order">我的商品</div>
                <div class="nothing">这里什么也没有哦，赶紧去添加商品吧</div>
                `
            }else{
                document.getElementById("myMessage").innerHTML = `
                <div class="order">我的商品</div>
                    <div class="myGoods">
                            <table id="table">
                                <thead class="thead">
                                <tr>
                                    <th class="th1">商品信息</th>
                                    <th class="th2">当前价</th>
                                    <th class="th4">库存</th>
                                    <th class="th5">累计销量</th>
                                    <th class="th6">上架时间</th>
                                    <th class="th7">操作</th>
                                </tr>
                                </thead>
                                <tbody id="tbody">
                                </tbody>
                            </table>
                    </div>
                `
                for(let i = 0;i<list.length;i++){
                    document.getElementById("tbody").innerHTML += `
                    <tr>
                    <td>
                        <img src="${list[i][0].cover}">
                        <div class="message">${list[i][0].goodsName}</div>
                    </td>
                    <td>
                        <div class="price">${list[i][0].goodsPrice}</div>
                        <div class="changeprice">修改价格</div>
                    </td>
                    <td>
                        <div class="stock">${list[i][0].stock}</div>
                        <div class="changestock">修改库存</div>
                    </td>
                    <td>
                        <div class="sold">${list[i][0].monthlySales}</div>
                    </td>
                    <td>
                        <div class="time">${list[i][0].time}</div>
                    </td>
                    <td>
                        <div class="change" onclick="changeOneGood(${list[i][0].goodsId},${pagelist.pageNo})">编辑</div>
                        <div class="takeOff" onclick="deleteOneGood(${list[i][0].goodsId},${pagelist.pageNo})">下架</div>
                    </td>
                </tr>
                    `
                }
                if(pagelist.pageNoTotal <= 5){
                    var pages = document.querySelectorAll(".page")
                    document.getElementById("pagebox").innerHTML = ``
                    for(let i=1;i<=pagelist.pageNoTotal;i++){
                        document.getElementById("pagebox").innerHTML += `
                        <button class="page">${i}</button>
                        `
                    }
                    pages[pageNo-1].style.backgroundColor = "#F96C0C"
                    pages[pageNo-1].style.color = "white"
                }else{
                    console.log(pagelist.pageNoTotal)
                    if(pageNo<=2){
                        console.log(pagelist)
                        console.log(pageSize)
                        document.getElementById("pagebox").innerHTML = ``
                        for(let i=1;i<=5;i++){
                            document.getElementById("pagebox").innerHTML += `
                            <button class="page">${i}</button>
                            `
                        }
                        var pages = document.querySelectorAll(".page")
                        for(let j=0;j<5;j++){
                            pages[j].style.backgroundColor = "wheat"
                            pages[j].style.color = "black"
                        }
                        pages[pageNo-1].style.backgroundColor = "#F96C0C"
                        pages[pageNo-1].style.color = "white"
                    }else if(pageNo >= pagelist.pageNoTotal-1){
                        console.log(pagelist)
                        document.getElementById("pagebox").innerHTML = ``
                        for(let i=1;i<=5;i++){
                            document.getElementById("pagebox").innerHTML += `
                            <button class="page">${pagelist.pageNoTotal+i-5}</button>
                            `
                        }
                        var pages = document.querySelectorAll(".page")
                        for(let j=0;j<5;j++){
                            pages[j].style.backgroundColor = "wheat"
                            pages[j].style.color = "black"
                        }
                        pages[pageNo-pagelist.pageNoTotal+4].style.backgroundColor = "#F96C0C"
                        pages[pageNo-pagelist.pageNoTotal+4].style.color = "white"
                    }else{
                        console.log(pagelist)
                        document.getElementById("pagebox").innerHTML = ``
                        for(let i=1;i<=5;i++){
                            document.getElementById("pagebox").innerHTML += `
                            <button class="page">${pageNo+i-3}</button>
                            `
                        }
                        var pages = document.querySelectorAll(".page")
                        for(let j=0;j<5;j++){
                            pages[j].style.backgroundColor = "wheat"
                            pages[j].style.color = "black"
                        }
                        pages[2].style.backgroundColor = "#F96C0C"
                        pages[2].style.color = "white"
                    }
                }
            }
            var a = 1;
            var pages = document.querySelectorAll(".page")
            for(let i=0;i<pages.length;i++){
                pages[i].onclick = () =>{     //这个点击事件只是切换到第几页
                    a = parseInt(pages[i].innerHTML)
                    console.log(a)
                    getGoodinShop(a)
                }
            }
            document.getElementById("leftbtn").onclick = () =>{
                if(pageNo == 1){
                    document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>页数不可以小于1</div><button onclick='closethis()' class='newbtn'>确定</button>`;
                    document.getElementById("floatContent").classList.remove("hide");
                }else{
                    a = pageNo - 1
                    getGoodinShop(a)
                }
            }
            document.getElementById("rightbtn").onclick = () =>{
                console.log(pagelist.pageNoTotal)
                if(pageNo == pagelist.pageNoTotal){
                    document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>后面没有内容了</div><button onclick='closethis()' class='newbtn'>确定</button>`;
                    document.getElementById("floatContent").classList.remove("hide");
                }else{
                    a = pageNo + 1
                    getGoodinShop(a)
                }
            }
            document.getElementById("jumpto").onclick = () =>{
                var pagenumber = parseInt(document.getElementById("pagenumber").value)
                if(pagenumber>=1&&pagenumber<=pagelist.pageNoTotal){
                    console.log(pagenumber)
                    getGoodinShop(pagenumber)
                }
            }
            document.getElementById("turnToFirst").onclick = () =>{
                getGoodinShop(1)
            }
            document.getElementById("turnToLast").onclick = () =>{
                var b =parseInt(pagelist.pageNoTotal) 
                getGoodinShop(b-1)
            }
        }else{
            console.log(data.data.data.data)
            document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>${data.data.data.data}</div><button onclick='closethis()' class='newbtn'>确定</button>`;
            document.getElementById("floatContent").classList.remove("hide");
        }
    }).catch(function (error){
        console.log(error)
        document.getElementById("floatContent").innerHTML ="<div>"+ "很抱歉"+"</div>"+"<div>"+"请检查网络情况"+"</div>"+"<button onclick='closethis()' class='newbtn'>"+"确定"+"</button>";
        document.getElementById("floatContent").classList.remove("hide");
    })
}

//---------------------------------------------------------------------------------------------//
function shopmessages (){
    var shopId = sessionStorage.getItem("shopId")
    axios.get('/home/shopstage/bussiness/getShopInfo',{
        params:{
            shopId:shopId
        }
    }).then(function(data){
        console.log(data.data.data)
        if(data.data.data.code==20000){
            var list = data.data.data.data
            console.log(list)
            document.querySelector(".bodyMain").innerHTML=`
            <div class="myMessage" id="myMessage"></div>
            `
            document.getElementById("myMessage").innerHTML=`
            <div class="order">店铺信息</div>
                <div class="shopmessage">
                    <div class="form-group">
                        <label for="name">店铺名称&nbsp;:&nbsp;</label>
                        <input type="text" class="form-control name" name="name" id="shopname" placeholder="店铺名称">
                    </div>
                    <div class="goodPhoto">
                        店铺标志
                        <div class="discribe">图片要求：宽高相等，大于110px，大小在1M内&nbsp;&nbsp;<button id="clear">重置</button></div>
                        <div class="photos">
                            <input id="ipt" type="file" onchange="previewFile()"> <!-- multiple 规定输入字段可接受多个值 -->
                            <div id="preview" class="inImg img">
                                <img class="img" src="../../static/home/img/add.png">
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="address">店铺地址&nbsp;:&nbsp;</label>
                        <input type="text" class="form-control address" name="address" id="shopaddress" placeholder="店铺地址">
                    </div>
                    <div class="form-group">
                        <label for="tel">店铺描述&nbsp;:&nbsp;</label>
                        <input type="text" class="form-control tel" name="int" id="introduction" placeholder="店铺描述">
                    </div>
                </div>
                <div class="save"><button onclick="changeShopMes(${list.userId})">保存</button></div>
            `
            document.getElementById("shopname").value = list.shopName
            document.getElementById("shopaddress").value = list.shopAddress
            document.getElementById("introduction").value = list.introduction
        }else{
            document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>${data.data.data.data}</div><button onclick='closethis()' class='newbtn'>确定</button>`;
            document.getElementById("floatContent").classList.remove("hide");
        }
    }).catch(function (error){
        console.log(error)
        document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>请检查网络是否连接</div><button onclick='closethis()' class='newbtn'>确定</button>`;
        document.getElementById("floatContent").classList.remove("hide");
    })
}
function changeShopMes(userId){
    var shopId = sessionStorage.getItem("shopId")
    var shopName = document.getElementById("shopname").value
    var shopAddress = document.getElementById("shopaddress").value
    var introduction = document.getElementById("introduction").value 
    axios.post('/home/shopstage/bussiness/updateShopInfo',{
        params:{
            shopName:shopName,
            shopAddress:shopAddress,
            introduction:introduction,
            shopId:shopId,
            userId:userId
        }
    }).then(function(data){
        if(data.data.data.code==20000){
            document.getElementById("floatContent").innerHTML =`<div>${data.data.data.data}</div><button onclick='closethis()' class='newbtn'>确定</button>`;
            document.getElementById("floatContent").classList.remove("hide");
        }else{
            document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>${data.data.data.data}</div><button onclick='closethis()' class='newbtn'>确定</button>`;
            document.getElementById("floatContent").classList.remove("hide");
        }
    }).catch(function (error){
        console.log(error)
        document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>请检查网络是否连接</div><button onclick='closethis()' class='newbtn'>确定</button>`;
        document.getElementById("floatContent").classList.remove("hide");
    })
}
function previewFile() {
    var oImg = document.getElementById('oImg');
    var file = document.getElementById('ipt').files[0];
    // console.log(file)
    var reader = new FileReader();
    
    reader.addEventListener('load', function() {
        oImg.src = this.result;
        img = oImg.src;
        uploadPhoto()
    }, false);
    if (file) {
        reader.readAsDataURL(file);
    }
}

function uploadPhoto(){
    img = document.getElementById('oImg').src
    // console.log(img)
    // axios.put('/home/center/user/uploadHeadImg',{
    //     params:{                
    //         img:img,
    //         userId:15
    //     }
    // }).then(function(data){
    //     if (data.data.data.code == 20000) {
    //         var list = data.data;
    //         console.log(list)
    //         document.getElementById("floatContent").innerHTML =`<div>${data.data.data.data}</div><button onclick='closethis()' class='newbtn'>确定</button>`;
    //         document.getElementById("floatContent").classList.remove("hide");
    //     } else {
    //         document.getElementById("floatContent").innerHTML = `<div>${data.data.data.data}</div><button onclick='closethis()' class='newbtn'>确定</button>`;
    //         document.getElementById("floatContent").classList.remove("hide");
    //     }
    // }).catch(function(error){
    //     console.log(error)
    //     document.getElementById("floatContent").innerHTML =`<div>${error}</div><button onclick='closethis()' class='newbtn'>确定</button>`;
    //     document.getElementById("floatContent").classList.remove("hide");
    // })
    var file = document.getElementById('ipt');
    console.log(file.files[0]);
    var formData = new FormData()
    formData.append('multipartFile',file.files[0]);
    // axios({
    //     url: `/home/center/user/uploadHeadImg?userId=15`,
    //     data: formData,
    //     method: 'put'
    // }).then((data) => {
    //     console.log(data)   
    //     // if(data.data.data.code==20000){
    //     //    alert("qqqqqqqq")
    //     // }
    // }).catch((err) => {
    //     console.log(err)
    // })
}



//---------------------------------------------------------------------------------------------//


function deleteOneGood(goodsId,pageNo){
    console.log(goodsId)
    axios.delete('/home/shopstage/bussiness/deleteOneGood',{
        params:{
            goodsId:goodsId
        }
    }).then(function(data){
        if(data.data.data.code==20000){
            document.getElementById("floatContent").innerHTML ="<div>"+"下架成功"+"</div>"+"<button onclick='closethis()' class='newbtn'>"+"确定"+"</button>";
            document.getElementById("floatContent").classList.remove("hide");
        }else{
            document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>${data.data.data.data}</div><button onclick='closethis()' class='newbtn'>确定</button>`;
            document.getElementById("floatContent").classList.remove("hide");
        }
        getGoodinShop(pageNo)
    }).catch(function (error){
        console.log(error)
        document.getElementById("floatContent").innerHTML ="<div>"+ "很抱歉"+"</div>"+"<div>"+"请检查网络情况"+"</div>"+"<button onclick='closethis()' class='newbtn'>"+"确定"+"</button>";
        document.getElementById("floatContent").classList.remove("hide");
    })
}
function changeOneGood(goodsId,pageNo){
    console.log(goodsId)
    document.getElementById("changeContent").innerHTML=`
    <div class="addForm">
        <div class="goodPhoto">
            商品封面
            <div class="discribe">图片要求：宽高大于100px，大小在1M内&nbsp;&nbsp;</div>
            <div class="photos">
                <input id="ipt" type="file" onchange="previewFile()"> <!-- multiple 规定输入字段可接受多个值 -->
                <div id="pre" class="inImg">
                    <img src="../../static/home/img/add.png" class="imgFir" id="oImg">
                </div>
            </div>
        </div>
        <div class="form-group">
            <label for="name">店铺名称&nbsp;:&nbsp;</label>
            <input type="text" class="form-control" name="shopName" id="shopName" placeholder="店铺名称">
        </div>
        <div class="form-group">
            <label for="introduction">商品信息&nbsp;:&nbsp;</label>
            <input type="text" class="form-control" name="introduction" id="introduction" placeholder="店铺简介">
        </div>
        <div class="form-group">
            <label for="address">店铺地址&nbsp;:&nbsp;</label>
            <input type="address" class="form-control" name="address" id="address" placeholder="店铺地址">
        </div>
        <button id="changeThis" onclick="addYourShop()">确认</button>
        <button id="giveup" onclick="giveup()">取消</button>
    </div>
    `
    document.getElementById("changeContent").classList.remove("hide");
    axios.delete('/home/shopstage/bussiness/changeOneGood',{
        params:{
            goodsId:goodsId
        }
    }).then(function(data){
        if(data.data.data.code==20000){
            document.getElementById("floatContent").innerHTML ="<div>"+"修改成功"+"</div>"+"<button onclick='closethis()' class='newbtn'>"+"确定"+"</button>";
            document.getElementById("floatContent").classList.remove("hide");
        }else{
            document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>${data.data.data.data}</div><button onclick='closethis()' class='newbtn'>确定</button>`;
            document.getElementById("floatContent").classList.remove("hide");
        }
        getGoodinShop(pageNo)
    }).catch(function (error){
        console.log(error)
        document.getElementById("floatContent").innerHTML ="<div>"+ "很抱歉"+"</div>"+"<div>"+"请检查网络情况"+"</div>"+"<button onclick='closethis()' class='newbtn'>"+"确定"+"</button>";
        document.getElementById("floatContent").classList.remove("hide");
    })
}
function searchMyShops(){
        document.querySelector(".bodyMain").innerHTML=`
        <div class="myMessage" id="myMessage"></div>
        `
        axios.get('/home/shopstage/bussiness/getAllShops',{
            params:{
                
            }
        }).then(function(data){
            if(data.data.data.code==20000){
                var list = data.data.data.data
                console.log("--------------------")
                console.log(list)
                if(list.length == 0){
                    document.getElementById("myMessage").innerHTML = ``
                    document.getElementById("myMessage").innerHTML += `
                    <div class="order">我的商品</div>
                    <div class="nothing">这里什么也没有哦，赶紧去添加商品吧</div>
                    `
                }else{
                    document.getElementById("bodyMain").innerHTML=`
                    <div class="myMessage" id="myMessage">
                    </div>
                    <button class="addShop" onclick="addShop()">
                    添加店铺
                    </button>
                    `
                    document.getElementById("myMessage").innerHTML=`<div class="order">我的店铺</div>`
                    for(i=0;i<list.length;i++){
                        document.getElementById("myMessage").innerHTML +=`
                        <div class="myShops">
                            <div class="shopname" id="shopname">${list[i].shopName}</div>
                            <div class="shopchoose">
                                <div class="shopTops">默认店铺</div>
                                <input class="default" type="checkbox">
                            </div>
                            <div class="shopsign">
                                <img src="${list[i].cover}">
                            </div>
                            <div class="shopnews">
                                <div class="shopTops">店铺消息</div>
                                <div class="news">
                                    <div class="addedOrder">新增订单:0</div>
                                    <div class="addedTalk">新增评论:0</div>
                                    <div class="addedSee">店铺信誉:${list[i].shopScore}</div>
                                    <div class="addedReturn">退货申请:0</div>
                                </div>
                            </div>
                            <div class="thisAddress">
                                <div class="shopTops">店铺地址</div>
                                <div class="thisAddre">${list[i].shopAddress}</div>
                            </div>
                            <div class="shopoperate">
                                <div class="shopTops">店铺操作</div>
                                <div class="operates">
                                    <button onclick="deleteThisShop(${list[i].shopId})">注销店铺</button>
                                    <button onclick="enterThisShop(${list[i].shopId})">进入店铺</button>
                                </div>
                            </div>
                        </div>
                        `
                    }
                    sessionStorage.setItem("shopId",list[0].shopId)
                }
            }else{
                console.log(data.data.data)
                document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>${data.data.data.data}</div><button onclick='closethis()' class='newbtn'>确定</button>`;
                document.getElementById("floatContent").classList.remove("hide");
            }
        }).catch(function (error){
            console.log(error)
            document.getElementById("floatContent").innerHTML ="<div>"+ "很抱歉"+"</div>"+"<div>"+"请检查网络情况"+"</div>"+"<button onclick='closethis()' class='newbtn'>"+"确定"+"</button>";
            document.getElementById("floatContent").classList.remove("hide");
        })
    }
    (function(){searchMyShops()})();
    function enterThisShop(shopId){
        sessionStorage.removeItem("shopId")
        sessionStorage.setItem("shopId",shopId)
    }
function deleteThisShop(shopId){
    axios.delete('/home/shopstage/bussiness/deleteShop',{
        params:{
            shopId:shopId,
        }
    }).then(function(data){
        if(data.data.data.code==20000){
            var list = data.data.data.data
            console.log("--------------------")
            console.log(list) 
            document.getElementById("floatContent").innerHTML =`<div>${data.data.data.data}</div><button onclick='closethis()' class='newbtn'>确定</button>`;
            document.getElementById("floatContent").classList.remove("hide");
            searchMyShops();
        }else{
            document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>${data.data.data.data}</div><button onclick='closethis()' class='newbtn'>确定</button>`;
            document.getElementById("floatContent").classList.remove("hide");
        }
    }).catch(function (error){
        console.log(error)
        document.getElementById("floatContent").innerHTML ="<div>"+ "很抱歉"+"</div>"+"<div>"+"请检查网络情况"+"</div>"+"<button onclick='closethis()' class='newbtn'>"+"确定"+"</button>";
        document.getElementById("floatContent").classList.remove("hide");
    })
}
function jumpTosearchComments(){
    jumpto()
    searchComments(1);
}
function searchComments(pageNo){
    var shopId = sessionStorage.getItem("shopId")
    document.getElementById("pageSize").onchange = function(){
        searchComments(1);
    }
    let pageSize =parseInt(document.getElementById("pageSize").value)
    axios.get('/home/shopstage/comment/getAllCommentsByPage',{
        params:{
            shopId:shopId,
            page:pageNo,
            pageSize:pageSize
        }
    }).then(function(data){
        console.log(data.data.data)
        console.log(shopId);
        if(data.data.data.code==20000){
            var list = data.data.data.data
            var pagelist = data.data.data.page
            if(list == "该店铺尚无评论"){
                console.log(10086)
                document.getElementById("bodyMain").innerHTML = `
                <div class="myMessage" id="myMessage"></div>
                `
                document.getElementById("myMessage").innerHTML = ``
                document.getElementById("myMessage").innerHTML += `
                <div class="nothing">这里什么也没有哦，赶紧去宣传一下你的店铺吧</div>
                `
            }else{
                document.getElementById("myMessage").innerHTML=`<div class="order">店铺评论</div>`
                for(let i = 0;i<list.length;i++){
                    document.getElementById("myMessage").innerHTML += `
                    <div class="comment">
                        <div class="commenterMessage">
                            <div class="userimg">
                                <img src="${list[i].img}">
                            </div>
                            <div class="usermessage">
                                ${list[i].nickName}
                            </div>
                        </div>
                        <div class="commentContent">
                            <div class="goodmes">${list[i].time}</div>
                            <div class="commentsays">${list[i].gcomment}</div>
                            <div class="thumb"><i class="thumb-up"></i>${list[i].thumbs}</div>
                        </div>
                    </div>
                    `
                }
                if(pagelist.pageNoTotal <= 5){
                    document.getElementById("pagebox").innerHTML = ``
                    for(let i=1;i<=pagelist.pageNoTotal;i++){
                        document.getElementById("pagebox").innerHTML += `
                        <button class="page">${i}</button>
                        `
                    }
                    var pages = document.querySelectorAll(".page")
                    pages[pageNo-1].style.backgroundColor = "#F96C0C"
                    pages[pageNo-1].style.color = "white"
                }else{
                    console.log(pagelist.pageNoTotal)
                    if(pageNo<=2){
                        document.getElementById("pagebox").innerHTML = ``
                        for(let i=1;i<=5;i++){
                            document.getElementById("pagebox").innerHTML += `
                            <button class="page">${i}</button>
                            `
                        }
                        var pages = document.querySelectorAll(".page")
                        for(let j=0;j<5;j++){
                            pages[j].style.backgroundColor = "wheat"
                            pages[j].style.color = "black"
                        }
                        pages[pageNo-1].style.backgroundColor = "#F96C0C"
                        pages[pageNo-1].style.color = "white"
                    }else if(pageNo >= pagelist.pageNoTotal-1){
                        console.log(pagelist)
                        document.getElementById("pagebox").innerHTML = ``
                        for(let i=1;i<=5;i++){
                            document.getElementById("pagebox").innerHTML += `
                            <button class="page">${pagelist.pageNoTotal+i-5}</button>
                            `
                        }
                        var pages = document.querySelectorAll(".page")
                        for(let j=0;j<5;j++){
                            pages[j].style.backgroundColor = "wheat"
                            pages[j].style.color = "black"
                        }
                        pages[pageNo-pagelist.pageNoTotal+4].style.backgroundColor = "#F96C0C"
                        pages[pageNo-pagelist.pageNoTotal+4].style.color = "white"
                    }else{
                        document.getElementById("pagebox").innerHTML = ``
                        for(let i=1;i<=5;i++){
                            document.getElementById("pagebox").innerHTML += `
                            <button class="page">${pageNo+i-3}</button>
                            `
                        }
                        var pages = document.querySelectorAll(".page")
                        for(let j=0;j<5;j++){
                            pages[j].style.backgroundColor = "wheat"
                            pages[j].style.color = "black"
                        }
                        pages[2].style.backgroundColor = "#F96C0C"
                        pages[2].style.color = "white"
                    }
                }
                var a = 1;
            var pages = document.querySelectorAll(".page")
            for(let i=0;i<pages.length;i++){
                pages[i].onclick = () =>{     //这个点击事件只是切换到第几页
                    a = parseInt(pages[i].innerHTML)
                    console.log(a)
                    searchComments(a)
                }
            }
            document.getElementById("leftbtn").onclick = () =>{
                if(pageNo == 1){
                    document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>页数不可以小于1</div><button onclick='closethis()' class='newbtn'>确定</button>`;
                    document.getElementById("floatContent").classList.remove("hide");
                }else{
                    a = pageNo - 1
                    searchComments(a)
                }
            }
            document.getElementById("rightbtn").onclick = () =>{
                console.log(pagelist.pageNoTotal)
                if(pageNo == pagelist.pageNoTotal){
                    document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>后面没有内容了</div><button onclick='closethis()' class='newbtn'>确定</button>`;
                    document.getElementById("floatContent").classList.remove("hide");
                }else{
                    a = pageNo + 1
                    searchComments(a)
                }
            }
            document.getElementById("jumpto").onclick = () =>{
                var pagenumber = parseInt(document.getElementById("pagenumber").value)
                if(pagenumber>=1&&pagenumber<=pagelist.pageNoTotal){
                    console.log(pagenumber)
                    searchComments(pagenumber)
                }
            }
            document.getElementById("turnToFirst").onclick = () =>{
                searchComments(1)
            }
            document.getElementById("turnToLast").onclick = () =>{
                var b =parseInt(pagelist.pageNoTotal) 
                searchComments(b-1)
            }
            }
        }else{
            console.log(10085)
            console.log(data.data.data.data)
            document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>${data.data.data.data}</div><button onclick='closethis()' class='newbtn'>确定</button>`;
            document.getElementById("floatContent").classList.remove("hide");
        }
    }).catch(function (error){
        console.log(error)
        document.getElementById("floatContent").innerHTML ="<div>"+ "很抱歉"+"</div>"+"<div>"+"请检查网络情况"+"</div>"+"<button onclick='closethis()' class='newbtn'>"+"确定"+"</button>";
        document.getElementById("floatContent").classList.remove("hide");
    })
}
function jumpTosearchMyOrders(){
    jumpto()
    searchMyOrders(1);
}
function searchMyOrders(pageNo){
    var shopId = sessionStorage.getItem("shopId")
    document.getElementById("pageSize").onchange = function(){
        searchMyOrders(1);
    }
    let pageSize =parseInt(document.getElementById("pageSize").value)
    axios.get('/home/shopstage/bussiness/getAllOrderByShopId',{
        params:{
            shopId:shopId,
            page:pageNo,
            pageSize:pageSize
        }
    }).then(function(data){
        console.log(data)
        console.log(shopId)
        if(data.data.data.code==20000){
            var list = data.data.data.data
            var pagelist = data.data.data.page
            if(list.length == 0){
                document.getElementById("myMessage").innerHTML = ``
                document.getElementById("myMessage").innerHTML += `
                <div class="order">全部订单</div>
                <div class="nothing">这里什么也没有哦，赶紧去宣传一下你的店铺吧</div>
                `
            }else{
                document.getElementById("myMessage").innerHTML=`<div class="order">订单管理</div>
                <div class="myOrders">
                    <table id="table">
                        <thead class="thead">
                            <tr>
                                <th class="th8">订单信息</th>
                                <th class="th9">购买数量</th>
                                <th class="th10">订单状态</th>
                                <th class="th11">操作</th>
                            </tr>
                        </thead>
                        <tbody id="tbody">
                        </tbody>
                    </table>
                </div>
                `
                for(let i = 0;i<list.length;i++){
                    if(list[i].setting == 0){
                        var set = "未付款"
                    }else if(list[i].setting == 1){
                        var set = "已付款"
                    }else{
                        var set = "已删除"
                    }
                    if(list[i].handle == 0){
                        var han = "未发货"
                    }else{
                        var han = "已发货"
                    }
                    if((list[i].setting == 1)&&(list[i].handle == 0)){
                        var hideornot = " "
                    }else{
                        var hideornot = "发货"
                    }
                    var time = list[i].time
                    time = time.substr(0,19)
                    time = time.replace(/T/,"&nbsp&nbsp&nbsp");
                    document.getElementById("tbody").innerHTML += `
                                <tr>
                                    <td>
                                    <div class="orderMess">
                                        订单号：${list[i].orderNo}</br>
                                        ${time}
                                    </div>
                                    </td>
                                    <td>
                                        ${list[i].count}
                                    </td>
                                    <td>
                                    ${set}</br>
                                    ${han}
                                    </td>
                                    <td>
                                        <div class="information">订单详情</div>
                                        <div class="payMessage">交付信息</div>
                                        <div class="refuse">拒接订单</div>
                                        <div class="sendExpress ${hideornot}" onclick="addexp(${list[i].orderId})">发货</div>
                                    </td>
                                </tr>
                    `
                }
                if(pagelist.pageNoTotal <= 5){
                    document.getElementById("pagebox").innerHTML = ``
                    for(let i=1;i<=pagelist.pageNoTotal;i++){
                        document.getElementById("pagebox").innerHTML += `
                        <button class="page">${i}</button>
                        `
                    }
                    var pages = document.querySelectorAll(".page")
                    pages[pageNo-1].style.backgroundColor = "#F96C0C"
                    pages[pageNo-1].style.color = "white"
                }else{
                    console.log(pagelist.pageNoTotal)
                    if(pageNo<=2){
                        console.log(pagelist)
                        console.log(pageSize)
                        document.getElementById("pagebox").innerHTML = ``
                        for(let i=1;i<=5;i++){
                            document.getElementById("pagebox").innerHTML += `
                            <button class="page">${i}</button>
                            `
                        }
                        var pages = document.querySelectorAll(".page")
                        for(let j=0;j<5;j++){
                            pages[j].style.backgroundColor = "wheat"
                            pages[j].style.color = "black"
                        }
                        pages[pageNo-1].style.backgroundColor = "#F96C0C"
                        pages[pageNo-1].style.color = "white"
                    }else if(pageNo >= pagelist.pageNoTotal-1){
                        console.log(pagelist)
                        document.getElementById("pagebox").innerHTML = ``
                        for(let i=1;i<=5;i++){
                            document.getElementById("pagebox").innerHTML += `
                            <button class="page">${pagelist.pageNoTotal+i-5}</button>
                            `
                        }
                        var pages = document.querySelectorAll(".page")
                        for(let j=0;j<5;j++){
                            pages[j].style.backgroundColor = "wheat"
                            pages[j].style.color = "black"
                        }
                        pages[pageNo-pagelist.pageNoTotal+4].style.backgroundColor = "#F96C0C"
                        pages[pageNo-pagelist.pageNoTotal+4].style.color = "white"
                    }else{
                        console.log(pagelist)
                        document.getElementById("pagebox").innerHTML = ``
                        for(let i=1;i<=5;i++){
                            document.getElementById("pagebox").innerHTML += `
                            <button class="page">${pageNo+i-3}</button>
                            `
                        }
                        var pages = document.querySelectorAll(".page")
                        for(let j=0;j<5;j++){
                            pages[j].style.backgroundColor = "wheat"
                            pages[j].style.color = "black"
                        }
                        pages[2].style.backgroundColor = "#F96C0C"
                        pages[2].style.color = "white"
                    }
                }
            }
            var a = 1;
            var pages = document.querySelectorAll(".page")
            for(let i=0;i<pages.length;i++){
                pages[i].onclick = () =>{     //这个点击事件只是切换到第几页
                    a = parseInt(pages[i].innerHTML)
                    console.log(a)
                    searchMyOrders(a)
                }
            }
            document.getElementById("leftbtn").onclick = () =>{
                if(pageNo == 1){
                    document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>页数不可以小于1</div><button onclick='closethis()' class='newbtn'>确定</button>`;
                    document.getElementById("floatContent").classList.remove("hide");
                }else{
                    a = pageNo - 1
                    searchMyOrders(a)
                }
            }
            document.getElementById("rightbtn").onclick = () =>{
                console.log(pagelist.pageNoTotal)
                if(pageNo == pagelist.pageNoTotal){
                    document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>后面没有内容了</div><button onclick='closethis()' class='newbtn'>确定</button>`;
                    document.getElementById("floatContent").classList.remove("hide");
                }else{
                    a = pageNo + 1
                    searchMyOrders(a)
                }
            }
            document.getElementById("jumpto").onclick = () =>{
                var pagenumber = parseInt(document.getElementById("pagenumber").value)
                if(pagenumber>=1&&pagenumber<=pagelist.pageNoTotal){
                    console.log(pagenumber)
                    searchMyOrders(pagenumber)
                }
            }
            document.getElementById("turnToFirst").onclick = () =>{
                searchMyOrders(1)
            }
            document.getElementById("turnToLast").onclick = () =>{
                var b =parseInt(pagelist.pageNoTotal) 
                searchMyOrders(b-1)
            }
        }else if(data.data.data.code==20001){
            document.querySelector(".bodyMain").innerHTML=`
            <div class="myMessage" id="myMessage">
                <div class="nothing">这里什么也没有哦，赶紧去宣传一下你的店铺吧</div>
            </div>
            `
        }else{
            console.log(data.data.data.data)
            document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>${data.data.data.data}</div><button onclick='closethis()' class='newbtn'>确定</button>`;
            document.getElementById("floatContent").classList.remove("hide");
        }
    }).catch(function (error){
        console.log(error)
        document.getElementById("floatContent").innerHTML ="<div>"+ "很抱歉"+"</div>"+"<div>"+"请检查网络情况"+"</div>"+"<button onclick='closethis()' class='newbtn'>"+"确定"+"</button>";
        document.getElementById("floatContent").classList.remove("hide");
    })
}
//-------------------------------------------------------------------------------------------------------//
//--------------------------------------------用户退款申请------------------------------------------------//
function userrefund(pageNo){
    jumpto()
    var shopId = sessionStorage.getItem("shopId")
    document.getElementById("pageSize").onchange = function(){
        userrefund(1);
    }
    let pageSize =parseInt(document.getElementById("pageSize").value)
    axios.get('/home/shopstage/bussiness/getAllRefundByShopId',{         
        params:{
            shopId:shopId,
            page:pageNo,
            pageSize:pageSize
        }
    }).then(function(data){
        if(data.data.data.code==20000){
            var list = data.data.data.data
            var pagelist = data.data.data.page
            if(list.length == 0){
                document.getElementById("myMessage").innerHTML = ``
                document.getElementById("myMessage").innerHTML += `
                <div class="order">退款申请</div>
                <div class="nothing">没有用户申请退款哦</div>
                `
            }else{
                document.querySelector(".bodyMain").innerHTML=`
                <div class="myMessage" id="myMessage">
                </div>
                <div id="paging">
                                <select name="pageSize" id="pageSize">
                                    <option value="5">5条/页</option>
                                    <option value="10">10条/页</option>
                                    <option value="15">15条/页</option>
                                </select>
                                <button id="turnToFirst">首页</button>
                                <span class="span">当前页数</span>
                                <i class="fa fa-angle-left fa-1g" aria-hidden="true" id="leftbtn"></i>
                                <span class="pagebox" id="pagebox">
                                    <button class="page">1</button>
                                    <button class="page">2</button>
                                    <button class="page">3</button>
                                    <button class="page">4</button>
                                    <button class="page">5</button>
                                </span>
                                <i class="fa fa-angle-right fa-1g" aria-hidden="true" id="rightbtn"></i>
                                <button id="turnToLast">尾页</button>
                                <input type="text" name="pagenumber" class="pagenumber" id="pagenumber" onkeyup="this.value=this.value.replace(/[^\d{0-9}]/g,'')" maxlength="2" placeholder="">页
                                <button class="jumpto" id="jumpto">跳转</button>
                            </div>
                `
                document.getElementById("myMessage").innerHTML=`<div class="order">订单管理</div>
                <div class="myOrders">
                    <table id="table">
                        <thead class="thead">
                            <tr>
                                <th class="th8">订单信息</th>
                                <th class="th9">购买数量</th>
                                <th class="th10">订单状态</th>
                                <th class="th11">操作</th>
                            </tr>
                        </thead>
                        <tbody id="tbody">
                        </tbody>
                    </table>
                </div>
                `
                for(let i = 0;i<list.length;i++){
                    if(list[i].setting == 0){
                        var set = "未付款"
                    }else if(list[i].setting == 1){
                        var set = "已付款"
                    }else{
                        var set = "已删除"
                    }
                    if(list[i].handle == 0){
                        var han = "未发货"
                    }else{
                        var han = "已发货"
                    }
                    if((list[i].setting == 1)&&(list[i].handle == 0)){
                        var hideornot = " "
                    }else{
                        var hideornot = "发货"
                    }
                    var time = list[i].time
                    time = time.substr(0,19)
                    time = time.replace(/T/,"&nbsp&nbsp&nbsp");
                    document.getElementById("tbody").innerHTML += `
                                <tr>
                                    <td>
                                    <div class="orderMess">
                                        订单号：${list[i].orderNo}</br>
                                        ${time}
                                    </div>
                                    </td>
                                    <td>
                                        ${list[i].count}
                                    </td>
                                    <td>
                                    ${set}</br>
                                    ${han}
                                    </td>
                                    <td>
                                        <div class="information">退款原因</div>
                                        <div class="payMessage" onclick="sureReason(${list[i].refundId})">同意退款</div>
                                        <div class="refuse" onclick="refuseReason(${list[i].refundId})">拒绝退款</div>
                                    </td>
                                </tr>
                    `
                }
                if(pagelist.pageNoTotal <= 5){
                    document.getElementById("pagebox").innerHTML = ``
                    for(let i=1;i<=pagelist.pageNoTotal;i++){
                        document.getElementById("pagebox").innerHTML += `
                        <button class="page">${i}</button>
                        `
                    }
                    var pages = document.querySelectorAll(".page")
                    pages[pageNo-1].style.backgroundColor = "#F96C0C"
                    pages[pageNo-1].style.color = "white"
                }else{
                    console.log(pagelist.pageNoTotal)
                    if(pageNo<=2){
                        console.log(pagelist)
                        console.log(pageSize)
                        document.getElementById("pagebox").innerHTML = ``
                        for(let i=1;i<=5;i++){
                            document.getElementById("pagebox").innerHTML += `
                            <button class="page">${i}</button>
                            `
                        }
                        var pages = document.querySelectorAll(".page")
                        for(let j=0;j<5;j++){
                            pages[j].style.backgroundColor = "wheat"
                            pages[j].style.color = "black"
                        }
                        pages[pageNo-1].style.backgroundColor = "#F96C0C"
                        pages[pageNo-1].style.color = "white"
                    }else if(pageNo >= pagelist.pageNoTotal-1){
                        console.log(pagelist)
                        document.getElementById("pagebox").innerHTML = ``
                        for(let i=1;i<=5;i++){
                            document.getElementById("pagebox").innerHTML += `
                            <button class="page">${pagelist.pageNoTotal+i-5}</button>
                            `
                        }
                        var pages = document.querySelectorAll(".page")
                        for(let j=0;j<5;j++){
                            pages[j].style.backgroundColor = "wheat"
                            pages[j].style.color = "black"
                        }
                        pages[pageNo-pagelist.pageNoTotal+4].style.backgroundColor = "#F96C0C"
                        pages[pageNo-pagelist.pageNoTotal+4].style.color = "white"
                    }else{
                        console.log(pagelist)
                        document.getElementById("pagebox").innerHTML = ``
                        for(let i=1;i<=5;i++){
                            document.getElementById("pagebox").innerHTML += `
                            <button class="page">${pageNo+i-3}</button>
                            `
                        }
                        var pages = document.querySelectorAll(".page")
                        for(let j=0;j<5;j++){
                            pages[j].style.backgroundColor = "wheat"
                            pages[j].style.color = "black"
                        }
                        pages[2].style.backgroundColor = "#F96C0C"
                        pages[2].style.color = "white"
                    }
                }
            }
            var a = 1;
            var pages = document.querySelectorAll(".page")
            for(let i=0;i<pages.length;i++){
                pages[i].onclick = () =>{     //这个点击事件只是切换到第几页
                    a = parseInt(pages[i].innerHTML)
                    console.log(a)
                    userrefund(a)
                }
            }
            document.getElementById("leftbtn").onclick = () =>{
                if(pageNo == 1){
                    document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>页数不可以小于1</div><button onclick='closethis()' class='newbtn'>确定</button>`;
                    document.getElementById("floatContent").classList.remove("hide");
                }else{
                    a = pageNo - 1
                    userrefund(a)
                }
            }
            document.getElementById("rightbtn").onclick = () =>{
                console.log(pagelist.pageNoTotal)
                if(pageNo == pagelist.pageNoTotal){
                    document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>后面没有内容了</div><button onclick='closethis()' class='newbtn'>确定</button>`;
                    document.getElementById("floatContent").classList.remove("hide");
                }else{
                    a = pageNo + 1
                    userrefund(a)
                }
            }
            document.getElementById("jumpto").onclick = () =>{
                var pagenumber = parseInt(document.getElementById("pagenumber").value)
                if(pagenumber>=1&&pagenumber<=pagelist.pageNoTotal){
                    console.log(pagenumber)
                    userrefund(pagenumber)
                }
            }
            document.getElementById("turnToFirst").onclick = () =>{
                userrefund(1)
            }
            document.getElementById("turnToLast").onclick = () =>{
                var b =parseInt(pagelist.pageNoTotal) 
                userrefund(b-1)
            }
        }else if(data.data.data.code==20001){
            document.querySelector(".bodyMain").innerHTML=`
            <div class="myMessage" id="myMessage">
                <div class="nothing">暂时还没有用户申请退款哟(๑•̀ㅂ•́)و✧</div>
            </div>
            `
        }else{
            console.log(data.data.data.data)
            document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>${data.data.data.data}</div><button onclick='closethis()' class='newbtn'>确定</button>`;
            document.getElementById("floatContent").classList.remove("hide");
        }
    }).catch(function (error){
        console.log(error)
        document.getElementById("floatContent").innerHTML ="<div>"+ "很抱歉"+"</div>"+"<div>"+"请检查网络情况"+"</div>"+"<button onclick='closethis()' class='newbtn'>"+"确定"+"</button>";
        document.getElementById("floatContent").classList.remove("hide");
    })
}
function refuseReason(refundId){
    document.getElementById("changeContent").innerHTML = `
            <div class="form-group">
                <label for="tel">拒绝原因&nbsp;:&nbsp;</label>
                <input type="text" class="form-control" name="address" id="refuseReason" placeholder="拒绝原因">
            </div>
            <button id="changeThis" onclick="refuse(${refundId});giveup()">确认</button>
            <button id="giveup" onclick="giveup()">取消</button>
    `
    document.getElementById("changeContent").classList.remove("hide")
}
function refuse(refundId){
    axios.put('/home/shopstage/refund/businessRefuse',{
        params:{
            refundId:refundId
        }
    }).then(function(data){
        if(data.data.data.code==20000){
            document.getElementById("floatContent").innerHTML =`<div>操作成功，正在审核中</div><button onclick='closethis()' class='newbtn'>确定</button>`;
            document.getElementById("floatContent").classList.remove("hide");
        }else{
            document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>${data.data.data.data}</div><button onclick='closethis()' class='newbtn'>确定</button>`;
            document.getElementById("floatContent").classList.remove("hide");
        }
    }).catch(function (error){
        console.log(error)
        document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>请检查网络连接/div><button onclick='closethis()' class='newbtn'>确定</button>`;
        document.getElementById("floatContent").classList.remove("hide");
    })
}
function sureReason(refundId){
//     document.getElementById("changeContent").innerHTML = `
//             <div class="form-group">
//                 <label for="tel">拒绝原因&nbsp;:&nbsp;</label>
//                 <input type="text" class="form-control" name="address" id="refuseReason" placeholder="拒绝原因">
//             </div>
//             <button id="changeThis" onclick="sure(${refundId});giveup()">确认</button>
//             <button id="giveup" onclick="giveup()">取消</button>
//     `
//     document.getElementById("changeContent").classList.remove("hide")
// }
// function sure(refundId){
    axios.put('/home/shopstage/refund/businessSure',{
        params:{
            refundId:refundId
        }
    }).then(function(data){
        if(data.data.data.code==20000){
            document.getElementById("floatContent").innerHTML =`<div>操作成功，请尽快退款</div><button onclick='closethis()' class='newbtn'>确定</button>`;
            document.getElementById("floatContent").classList.remove("hide");
        }else{
            document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>${data.data.data.data}</div><button onclick='closethis()' class='newbtn'>确定</button>`;
            document.getElementById("floatContent").classList.remove("hide");
        }
    }).catch(function (error){
        console.log(error)
        document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>请检查网络连接/div><button onclick='closethis()' class='newbtn'>确定</button>`;
        document.getElementById("floatContent").classList.remove("hide");
    })
}
//-------------------------------------------------------------------------------------------------------//
//-------------------------------------------------------------------------------------------------------//
function addexp(orderId){
    document.getElementById("changeContent").innerHTML = `
    <div class="expressChoose">
                快递品牌:
                <select name="expressBrandId" id="expressBrandId">
                    <option value="1">韵达</option>
                    <option value="2">圆通</option>
                    <option value="3">百世</option>
                    <option value="4">中通</option>
                    <option value="5">顺丰</option>
                    <option value="6">邮政</option>
                    <option value="7">京东</option>
                    <option value="8">申通</option>
                    <option value="9">EMS</option>
                </select>
                快递类型:
                <select name="expressTypeId" id="expressTypeId">
                    <option value="1">衣物</option>
                    <option value="2">箱包</option>
                    <option value="3">母婴</option>
                    <option value="4">鞋类</option>
                    <option value="5">美妆</option>
                    <option value="6">生鲜</option>
                    <option value="7">运动户外</option>
                    <option value="8">茶酒</option>
                    <option value="9">生活电器</option>
                    <option value="10">文具</option>
                    <option value="11">零食</option>
                    <option value="12">数码设备</option>
                    <option value="13">医疗保健</option>
                </select>
            </div>
            <div class="form-group">
                <label for="tel">商家备注&nbsp;:&nbsp;</label>
                <input type="text" class="form-control" name="address" id="remarks" placeholder="详细地址">
            </div>
            <div class="form-group">
                <label for="address">发货地址&nbsp;:&nbsp;</label>
                <input type="text" class="form-control" name="address" id="address" placeholder="详细地址">
            </div>
            <button id="changeThis" onclick="addExpress(${orderId});giveup()">确认</button>
            <button id="giveup" onclick="giveup()">取消</button>
    `
    document.getElementById("changeContent").classList.remove("hide")
}
function giveup(){
    document.getElementById("changeContent").classList.add("hide")
}
function addExpress(orderId){
var expressBrandId=document.getElementById("expressBrandId").value
var expressTypeId=document.getElementById("expressTypeId").value
var remarks=document.getElementById("remarks").value
var starting=document.getElementById("address").value
    axios.post('/home/shopstage/express/addExpress',{
        params:{
            expressBrandId:expressBrandId,
            expressTypeId:expressTypeId,
            orderId:orderId,
            remarks:remarks,
            starting:starting
        }
    }).then(function(data){
        if(data.data.data.code==20000){
            document.getElementById("floatContent").innerHTML =`<div>添加快递信息成功，请等待管理员审核</div><button onclick='closethis();sendSure(${data.data.data.data})' class='newbtn'>确定</button>`;
            document.getElementById("floatContent").classList.remove("hide");
        }else{
            document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>${data.data.data.data}</div><button onclick='closethis()' class='newbtn'>确定</button>`;
            document.getElementById("floatContent").classList.remove("hide");
        }
    }).catch(function (error){
        console.log(error)
        document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>请检查网络是否连接</div><button onclick='closethis()' class='newbtn'>确定</button>`;
        document.getElementById("floatContent").classList.remove("hide");
    })
}
function sendSure(expressId){
    document.getElementById("floatContent").innerHTML =`<div>请问您确定要发货吗</div><button onclick='closethis();sureSent(${expressId})' class='half；'>确定</button><button onclick='closethis()'class='half'>稍后</button>`;
    document.getElementById("floatContent").classList.remove("hide");
}
function sureSent(expressId){
    axios.put('/home/shopstage/express/businessSureSent',{
        params:{
            expressId:expressId
        }
    }).then(function(data){
        if(data.data.data.code==20000){
            document.getElementById("floatContent").innerHTML =`<div>操作成功，请联系快递发货</div><button onclick='closethis()' class='newbtn'>确定</button>`;
            document.getElementById("floatContent").classList.remove("hide");
        }else{
            document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>${data.data.data.data}</div><button onclick='closethis()' class='newbtn'>确定</button>`;
            document.getElementById("floatContent").classList.remove("hide");
        }
    }).catch(function (error){
        console.log(error)
        document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>请检查网络连接/div><button onclick='closethis()' class='newbtn'>确定</button>`;
        document.getElementById("floatContent").classList.remove("hide");
    })
}
function  closethis(){
    document.getElementById("floatContent").classList.add("hide");
}
function previewFile() {
    console.log(10)
    var oImg = document.getElementById('oImg');
    var file = document.getElementById('ipt').files[0];
    var reader = new FileReader();
    
    reader.addEventListener('load', function() {
        oImg.src = this.result;
        img = oImg.src;
    }, false);
    if (file) {
        reader.readAsDataURL(file);
    }
}
function addShop(){
    document.getElementById("changeContent").innerHTML=`
    <div class="addForm">
        <div class="goodPhoto">
            商品封面
            <div class="discribe">图片要求：宽高大于100px，大小在1M内&nbsp;&nbsp;</div>
            <div class="photos">
                <input id="ipt" type="file" onchange="previewFile()"> <!-- multiple 规定输入字段可接受多个值 -->
                <div id="pre" class="inImg">
                    <img src="../../static/home/img/add.png" class="imgFir" id="oImg">
                </div>
            </div>
        </div>
        <div class="form-group">
            <label for="name">店铺名称&nbsp;:&nbsp;</label>
            <input type="text" class="form-control" name="shopName" id="shopName" placeholder="店铺名称">
        </div>
        <div class="form-group">
            <label for="introduction">店铺简介&nbsp;:&nbsp;</label>
            <input type="text" class="form-control" name="introduction" id="introduction" placeholder="店铺简介">
        </div>
        <div class="form-group">
            <label for="address">店铺地址&nbsp;:&nbsp;</label>
            <input type="address" class="form-control" name="address" id="address" placeholder="店铺地址">
        </div>
        <button id="changeThis" onclick="addYourShop()">确认</button>
        <button id="giveup" onclick="giveup()">取消</button>
    </div>
    `
    document.getElementById("changeContent").classList.remove("hide");
}
function addYourShop(){
    var userId = document.getElementById("di").innerHTML
    console.log(userId)
    var shopName = document.getElementById("shopName").value
    var introduction = document.getElementById("introduction").value
    var shopAddress = document.getElementById("address").value
    img = document.getElementById('oImg').src
    var file = document.getElementById('ipt');
    var formData = new FormData()
    formData.append('multipartFile',file.files[0]);
    axios({
        url:'/home/shopstage/bussiness/addShop',
        data:formData,
        params:{
            userId:userId,
            introduction:introduction,
            shopAddress:shopAddress,
            shopName:shopName
        },
        method:'post'
    }).then(function(data){
        console.log(data)
        if(data.data.data.code == 20000){
            document.getElementById("changeContent").classList.add("hide");
            document.getElementById("floatContent").innerHTML =`<div>新增店铺成功</div><button onclick='closethis();searchMyShops()' class='newbtn'>确定</button>`;
            document.getElementById("floatContent").classList.remove("hide");
        }else{
            document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>${data.data.data.data}</div><button onclick='closethis()' class='newbtn'>确定</button>`;
            document.getElementById("floatContent").classList.remove("hide");
        }
    }).catch(function (error){
        console.log(error)
        document.getElementById("floatContent").innerHTML =`<div>很抱歉</div><div>请检查网络是否连接</div><button onclick='closethis()' class='newbtn'>确定</button>`;
        document.getElementById("floatContent").classList.remove("hide");
    })
}